package fons.navigator.ui.actions;

import java.awt.Dimension;
import java.awt.event.ActionEvent;

import fons.navigator.NavigatorMain;
import fons.navigator.ui.NavigatorMainFrame;
import fons.navigator.ui.windows.messages.MessagesWindow;

@ActionDescription(
		menu = "Fenster",
		name = "Meldungslog",
		description = "Zeigt eine Liste mit Meldungen des Navigators an"
)
public class MessagesAction extends NavigatorAbstractAction {
	private static final long serialVersionUID = 1L;
	
	public MessagesAction(NavigatorMainFrame app) {
		super(app, true);
	}
	
	@Override
	public void actionPerformed(ActionEvent evt) {
		final MessagesWindow messagesWindow = NavigatorMain.getMessagesWindow();
		
		if (messagesWindow.getWindow().getParent() == getApp().getDesktopPane()) {
			if (!messagesWindow.getWindow().isVisible()) {
				messagesWindow.getWindow().setVisible(true);
			}
			
		} else {
			getApp().getDesktopPane().add(messagesWindow.getWindow());

			messagesWindow.getWindow().setPreferredSize(new Dimension(600, 600));
			messagesWindow.getWindow().pack();
			messagesWindow.getWindow().setVisible(true);
		}
	}
}
